<template>
  <div id="options">
    <top-bar :title="title" v-show="IsTopbar"></top-bar>
    <div class="replace_one">
      <p class="phoneImg">
        <img src="@/assets/imgs/phone.png" />
      </p>
      <p class="phoneText">您的手机号：{{phone}}</p>
      <p class="phone_t">当前手机号为登录平台和司机联系您的重要号码， 请勿随意修改！</p>
      <p class="rzBtn" @click="phoneBtn">更换手机号</p>
    </div>
  </div>
</template>
<script>
import '@/assets/svgs/drjc_telephone.svg';
import '@/assets/svgs/yzm_icon.svg';
import { Tabs, Icon, Field, InputItem, Toast, Codebox, Dialog } from 'mand-mobile';
import TopBar from '@/components/TopBar';
import Loading from '@/components/loading';
import { decryptByDESModeEBC, encryptByDESModeEBC } from '@/common/encrypt';
import Utils from '@/common/pakjUtils';
import http from '@/common/http';
export default {
  components: {
    [Tabs.name]: Tabs,
    [Icon.name]: Icon,
    [TopBar.name]: TopBar,
    [Field.name]: Field,
    [Toast.name]: Toast,
    [Codebox.name]: Codebox,
    [InputItem.name]: InputItem
  },
  data() {
    return {
      title: '更换手机号',
      phone: '',
      user_phone: '',
      IsTopbar: true
    };
  },
  created() {
    if (Utils.isApp()) {
      // 判断当前环境是否在app
      this.IsTopbar = false;
    }
    Loading.show();
    http.post('/pakj/passenger/getUserInfo').then(res => {
      Loading.hide();
      console.log(res.data);
      if (res.data.code === '000000') {
        this.phone = this.startFun(decryptByDESModeEBC(res.data.data.user_phone), 3, 4);
        this.user_phone = res.data.data.user_phone;
      } else {
        Dialog.alert({
          title: '提示',
          content: res.data.msg,
          confirmText: '确定'
        });
      }
    });
  },
  methods: {
    phoneBtn() {
      this.$router.push({
        name: 'ReplacePhoneCaptcha',
        query: {
          userphone: decryptByDESModeEBC(this.user_phone)
        }
      });
    },
    startFun(str, frontLen, endLen) {
      var len = str.length - frontLen - endLen;
      var xing = '';
      for (var i = 0; i < len; i++) {
        xing += '*';
      }
      return str.substring(0, frontLen) + xing + str.substring(str.length - endLen);
    }
  }
};
</script>
<style lang="stylus" scoped>
p {
  display: block;
  margin-block-start: 0px;
  margin-block-end: 0px;
  margin-inline-start: 0px;
  margin-inline-end: 0px;
}

#options {
  height: 100vh;
}

.phoneImg {
  padding-top: 46px;
  text-align: center;
}

.phoneImg img {
  width: 100px;
  height: 160px;
}

.phoneText {
  margin-top: 62px;
  font-size: 36px;
  color: #333;
  text-align: center;
}

.set_text {
  text-align: center;
  padding: 42px 0px;
  font-size: 26px;
  color: #999;
}

.get-code-button {
  min-width: 160px;
  height: 48px;
  font-size: 24px;
  margin-right: 90px;
  display: inline-block;
  background-color: #FF6917;
  text-align: center;
  line-height: 48px;
  color: #fff;
  border-radius: 7px;
}

.phone_t {
  margin: 44px 80px 0px 80px;
  font-size: 26px;
  color: #999;
  text-align: center;
}

.rzBtn {
  height: 98px;
  line-height: 98px;
  font-size: 36px;
  text-align: center;
  background-color: #FF6917;
  color: #fff;
  margin: 60px 20px 0px 20px;
  border-radius: 7px;
}

.upper {
  margin-top: 62px;
  padding-left: 90px;
}

.title_hd {
  font-size: 44px;
  color: #333;
}

.desc {
  margin-bottom: 80px !important;
  font-size: 24px;
  color: #999;
  padding-left: 90px;
  padding-top: 10px;
}

.desc span {
  color: color-primary;
}

.captcha-input-box {
  .md-codebox {
    justify-content: flex-start;
  }
}

.yzm_code_text {
  font-size: 24px;
  color: #999;
  margin-top: 10px;
  padding-left: 90px;
}
</style>
